<%@page import="java.text.SimpleDateFormat"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" import="web_hr.*,java.sql.*,java.util.*,java.io.*,java.text.ParseException;"
    pageEncoding="UTF-8"%>


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css" href="../Res/Bootstrap/css/bootstrap.min.css">
<title>Insert title here</title>
</head>
<body class="container">
	<table class="table">
		<thead>
			<tr>
				<td>Sun</td><td>Mon</td><td>Tue</td><td>Wed</td>
				<td>Thu</td><td>Fri</td><td>Sat</td>
			</tr>
		</thead>
		<tbody>
		<%
		PrintWriter pw = response.getWriter();
		System.out.println("start");
/* 		//获取本月签到数据
		String username = (String)request.getParameter("username");
		System.out.println(username);
		Model time = new Model("hr_time");
		String sql = "select time from hr_time where username = '"+username+"' order by sta";
		ResultSet rs = time.eQuery(sql); */

		//获取本月第一天周几，结果类似“星期五”
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		SimpleDateFormat sdf1 = new SimpleDateFormat("F");
		Calendar calendar = Calendar.getInstance();
		int mon = calendar.get(Calendar.MONTH)+1; 
		int year = calendar.get(Calendar.YEAR); 
		String str=null;
		if(mon<10){
			str = year+"-0"+mon+"-"+"01";
		}else{
			str = year+"-"+mon+"-"+"01";
		}
		//获取本月最后一天
		int maxDay=calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
		java.text.Format formatter3=new java.text.SimpleDateFormat("yyyy-MM-"+maxDay);
		String lastDay = formatter3.format(calendar.getTime());
		System.out.println(lastDay);
		java.util.Date firstDay = null;
		try {
			firstDay = sdf.parse(str);
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		String week = sdf1.format(firstDay);
		//System.out.println(week);
		int i = Integer.parseInt(week);
		int flag=1;
		int count =0;
			pw.print("<tr>");
			for(int j=0;j<i;j++){
				pw.print("<td> </td>");
				count++;
			}
			if(count%7==0){ 
				pw.print("</tr><tr>");
			}
			
		//while(flag<=Integer.parseInt(lastDay)){
		while(flag<=30){
			pw.print("<td>"+flag+"</td>");
			flag++;
			count++;
			if(count%7==0) pw.print("</tr><tr>");
		}
		pw.print("</tr>");

		/*List list = new LinkedList();
		 for(int j=0;j<i;j++){
			list.add(" ");
		}
		try {
			while(rs.next()){
				list.add(String.valueOf(rs.getInt("time")));
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
			Iterator ite = list.iterator();
			while(flag < Integer.parseInt(lastDay)){
				if(flag%7==0) pw.print("<tr>");
				pw.print("<td>"+flag+"</td>");
				flag++;
				if(flag%7==0) pw.print("</tr>");
			} */
		%>
		</tbody>
	</table>
</body>
</html>
